﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using VOL.Entity.AttributeManager;
using VOL.Entity.DomainModels.WorkforceManage;
using VOL.SmartMecial.Dtos;
using VOL.SmartMecial.IServices.WorkforceManage;

namespace VOL.WebApi.Controllers.SmartMecial
{
    //[Route("api/[controller]/[action]")]
    //[ApiController]

    [Route("api/ReplaceWorkController")]
    [PermissionTable(Name = "ReplaceWorkController")]
    public class ReplaceWorkController : ControllerBase
    {
        private readonly IAddReplaceWorkService _service;
        private readonly IReplaceTableService _replaceTableService;
        private readonly IReplaceWorkService _replaceWork;
        private readonly IReplaceWorkShow _replaceWorkShow;
        private readonly IUpdateReplaceWorkService _updateReplaceWorkService;

        public ReplaceWorkController(IAddReplaceWorkService service, IReplaceTableService replaceTableService, IReplaceWorkService replaceWork, IReplaceWorkShow replaceWorkShow, IUpdateReplaceWorkService updateReplaceWorkService)
        {
            _service = service;
            _replaceTableService = replaceTableService;
            _replaceWork = replaceWork;
            _replaceWorkShow = replaceWorkShow;
            _updateReplaceWorkService = updateReplaceWorkService;
        }


        /// <summary>
        /// 添加申请替班
        /// </summary>
        /// <param name="model">实体</param>
        /// <returns></returns>

        [HttpPost("AddReplaceWork")]
        public async Task<int> AddReplaceWork([FromBody] ReplaceWorkModel model)
        {
            return await _service.AddReplaceWork(model);
        }

        /// <summary>
        /// 修改申请替班
        /// </summary>
        /// <param name="model">实体</param>
        /// <returns></returns>

        [HttpPost("UpdateReplaceWork")]
        public async Task<int> UpdateReplaceWork([FromBody] ReplaceWorkModel model)
        {
            var update = await _updateReplaceWorkService.UpdateReplaceWork(model);
            return update;
        }
        /// <summary>
        /// 替换人列表
        /// </summary>
        /// <returns></returns>
        [HttpGet("ReplaceTableShow")]
        public async Task<List<ReplaceTableModel>> ReplaceTableShow()
        {

            return await _replaceTableService.ReplaceTableShow();
        }



        /// <summary>
        /// 申请人列表
        /// </summary>
        /// <returns></returns>
        [HttpGet("ReplaceWorkShow")]
        public async Task<List<Nurse>> ReplaceWorkShow()
        {

            return await _replaceWork.ReplaceWorkShow();
        }

        /// <summary>
        /// 显示列表
        /// </summary>
        /// <returns></returns>
        [HttpGet("ReplaceWorkShows")]
        public async Task<List<ReplaceWorkDTO>> ReplaceWorkShows()
        {

            return await _replaceWorkShow.ReplaceWorkShows();
        }
        /// <summary>
        /// 修改审批状态
        /// </summary>
        /// <param name="id">id</param>
        /// <param name="auditState">审批状态</param>
        /// <returns></returns>
        [HttpPost("UpdateAuditState")]
        public async Task<object> UpdateAuditState(int id, string auditState, string auditComment)
        {
            return await _replaceWorkShow.UpdateAuditState(id, auditState, auditComment);
        }
    }
}
